<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/html"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>系统设置</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="robots" content="all,follow">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="/vendor/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="/vendor/font-awesome/css/font-awesome.min.css">
    <!-- Fontastic Custom icon font-->
    <link rel="stylesheet" href="/css/fontastic.css">
    <!-- Google fonts - Poppins -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,700">
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="/css/style.default.css" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" href="/css/custom.css">
    <!-- Favicon-->
    <link rel="shortcut icon" href="/images/favicon.ico">
    <!-- Tweaks for older IEs--><!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script><![endif]-->
    <!-- JavaScript files-->
    <script src="/vendor/jquery/jquery.min.js"></script>
    <script src="/vendor/popper.js/umd/popper.min.js"></script>
    <script src="/vendor/bootstrap/js/bootstrap.min.js"></script>
    <script src="/vendor/jquery.cookie/jquery.cookie.js"></script>
    <script src="/vendor/chart.js/Chart.min.js"></script>
    <script src="/vendor/jquery-validation/jquery.validate.min.js"></script>

    <!-- Main File-->
    <script src="/js/front.js"></script>

    <!-- 公共header js -->
    <script th:include="commons::header_js"></script>
</head>
<body>
<div class="page">
    <!-- Main Navbar-->
    <header th:include="commons::common_header"></header>

    <div class="page-content d-flex align-items-stretch">
        <!-- 在commons里面，sidebar -->
        <nav th:include="commons::common_sidebar" class="side-navbar"></nav>

        <div class="content-inner">
            <!-- Page Header-->
            <header class="page-header">
                <div class="container-fluid">
                    <h2 class="no-margin-bottom">系统设置</h2>
                </div>
            </header>
            <!-- 个人操作区域 -->
            <!-- ......... -->

            <div class="container">
                <!-- Nav tabs -->
                <ul class="nav nav-tabs" role="tablist">
                    <li class="nav-item">
                        <a class="nav-link active" data-toggle="tab" href="#vipsetting" id="vipsettingcilck">会员设置</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-toggle="tab" href="#cashsetting" id="cashsettingclick">计费设置</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-toggle="tab" href="#roomsetting" id="roomsettingclick">房间设置</a>
                    </li>
                    <shiro:hasAnyRoles name="超级管理员">
                    <li class="nav-item">
                        <a class="nav-link" data-toggle="tab" href="#clerksetting" id="clerksettingclick">操作员设置</a>
                    </li>
                    </shiro:hasAnyRoles>
                    <li class="nav-item">
                        <a class="nav-link" data-toggle="tab" href="#datacontrol">数据管理</a>
                    </li>
                </ul>

                <!-- Tab panes -->
                <div class="tab-content">
                    <div id="vipsetting" class="container tab-pane active"><!--会员设置-->

                        <!--表单遍历显示会员等级信息-->
                        <!--            <section class="dashboard-counts no-padding-bottom">-->
                        <div class="container-fluid">
                            <table class="table table-hover">
                                <thead class="table-primary">
                                <tr>
                                    <th>会员等级</th>
                                    <th>享受折扣</th>
                                    <th>积分下限</th>
                                    <th>积分上限</th>
                                    <th>修改</th>
                                    <th>删除</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr th:each="user_level : ${user_levels}" th:id="${user_level.level_id}">
                                    <!--foreach > User user :users -->
                                    <td th:text="${user_level.level_name}">普通会员</td>
                                    <td th:text="${user_level.level_discount}">9折</td>
                                    <td th:text="${user_level.level_min_credit}">500</td>
                                    <td th:text="${user_level.level_max_credit}">999</td>
                                    <td><!-- 按钮：用于打开模态框 -->
                                        <button type="button" class="btn btn-primary" data-toggle="modal"
                                                data-target="#myModal" style="height: 24px;line-height: 11px;"
                                                th:onclick="fillinput([[${user_level}]])">
                                            修改
                                        </button>

                                        <!-- 模态框 -->
                                        <div class="modal fade" id="myModal">
                                            <div class="modal-dialog">
                                                <div class="modal-content">

                                                    <!-- 模态框头部 -->
                                                    <div class="modal-header">
                                                        <h4 class="modal-title">会员规则单条修改</h4>
                                                        <button type="button" class="close" data-dismiss="modal">
                                                            &times;
                                                        </button>
                                                    </div>

                                                    <form action="/systemsetting/user_level/update" method="post">
                                                        <!-- 模态框主体 -->
                                                        <div class="modal-body">
                                                            <input type="hidden" th:value="${user_level.level_id}"
                                                                   name="level_id">
                                                            会员等级：<input type="text" th:value="${user_level.level_name}"
                                                                        onfocus="clearinput1()" id="modelinput1"
                                                                        name="level_name"><br>
                                                            享受折扣：<input type="text"
                                                                        th:value="${user_level.level_discount}"
                                                                        onfocus="clearinput2()" id="modelinput2"
                                                                        name="level_discount"><br>
                                                            积分下限：<input type="text"
                                                                        th:value="${user_level.level_min_credit}"
                                                                        onfocus="clearinput3()" id="modelinput3"
                                                                        name="level_min_credit"><br>
                                                            积分上限：<input type="text"
                                                                        th:value="${user_level.level_max_credit}"
                                                                        onfocus="clearinput4()" id="modelinput4"
                                                                        name="level_max_credit"><br>
                                                            <input type="hidden" name="flagValue"
                                                                   value="updateuser_level">

                                                        </div>

                                                        <!-- 模态框底部 -->
                                                        <div class="modal-footer">
                                                            <input type="submit" class="btn btn-primary" value="修改">
                                                            <button type="button" class="btn btn-primary"
                                                                    data-dismiss="modal">关闭
                                                            </button>
                                                        </div>
                                                    </form>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <button type="button" class="btn btn-primary" data-toggle="modal"
                                                style="height: 24px;line-height: 11px;"
                                                th:onclick="deleteItem([[${user_level.level_id}]])">
                                            删除
                                        </button>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                            <br>
                            <br>
                            <br>

                            <button type="button" class="btn btn-primary" data-toggle="modal"
                                    data-target="#myModal2" style="height: 24px;line-height: 11px;">
                                新增会员等级
                            </button>
                            <br>
                            <br>
                            <!-- 模态框 -->
                            <div class="modal fade" id="myModal2">
                                <div class="modal-dialog">
                                    <div class="modal-content">

                                        <!-- 模态框头部 -->
                                        <div class="modal-header">
                                            <h4 class="modal-title">会员规则单条修改</h4>
                                            <button type="button" class="close" data-dismiss="modal">
                                                &times;
                                            </button>
                                        </div>

                                        <form action="/systemsetting/user_level/additem" method="post">
                                            <!-- 模态框主体 -->
                                            <div class="modal-body">
                                                会员等级：<input type="text" onfocus="clearinput1()" id="modelinput1"
                                                            name="level_name"><br>
                                                享受折扣：<input type="text" onfocus="clearinput2()" id="modelinput2"
                                                            name="level_discount"><br>
                                                积分下限：<input type="text" onfocus="clearinput3()" id="modelinput3"
                                                            name="level_min_credit"><br>
                                                积分上限：<input type="text" onfocus="clearinput4()" id="modelinput4"
                                                            name="level_max_credit"><br>
                                                <input type="hidden" name="flagValue" value="''">
                                            </div>

                                            <!-- 模态框底部 -->
                                            <div class="modal-footer">
                                                <input type="submit" class="btn btn-primary" value="确认添加">
                                                <button type="button" class="btn btn-primary"
                                                        data-dismiss="modal">关闭
                                                </button>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                        </div>
                        <!--            </section>-->
                    </div>
                    <div id="cashsetting" class="container tab-pane fade"><br><!--计费设置-->
                        <div class="container-fluid">
                            <!--<form action="/systemsetting/room_type/discountall">全场打折相关-->
                            <table>
                                <tr>
                                    <th>&nbsp;&nbsp;请输入全场打折率并选择是否全场打折&nbsp;&nbsp;&nbsp;</th>
                                    <td><input type="text" id="discountforall" style="width: 90px;"
                                               name="room_type_discount" onfocus="clearinput6()">&nbsp;&nbsp;&nbsp;
                                    </td>
                                    <td style="height: 24px;line-height: 11px;"><label><input name="all_discount"
                                                                                              type="radio" value="true"
                                                                                              style="height: 24px;line-height: 11px;"/>是&nbsp;&nbsp;&nbsp;</label>
                                    </td>
                                    <td style="height: 24px;line-height: 11px;"><label><input name="all_discount"
                                                                                              type="radio" value="false"
                                                                                              style="height: 24px;line-height: 11px;"/>否&nbsp;&nbsp;&nbsp;</label>
                                    </td>
                                    <td><input type="submit" class="btn btn-primary"
                                               style="height: 24px;line-height: 11px;" value="确定并应用"
                                               th:onclick="discountall([[${room_types}]])"></td>
                                </tr>
                                <tr>
                                    <th>&nbsp;&nbsp;请选择是否在结账时自动取整&nbsp;&nbsp;&nbsp;</th>
                                    <td id="roundmoney"></td>
                                    <td style="height: 24px;line-height: 11px;"><label><input name="round_flag"
                                                                                              type="radio" value="true"
                                                                                              style="height: 24px;line-height: 11px;"/>是&nbsp;&nbsp;&nbsp;</label>
                                    </td>
                                    <td style="height: 24px;line-height: 11px;"><label><input name="round_flag"
                                                                                              type="radio" value="false"
                                                                                              style="height: 24px;line-height: 11px;"/>否&nbsp;&nbsp;&nbsp;</label>
                                    </td>
                                    <td><input type="submit" class="btn btn-primary"
                                               style="height: 24px;line-height: 11px;" value="确定并应用"
                                               th:onclick="roundmoney()"></td>
                                </tr>
                            </table>
                            <!--</form>-->

                            <table class="table table-hover">
                                <thead class="table-primary">
                                <tr>
                                    <th>房间类型</th>
                                    <th>房间价格</th>
                                    <th>房间折扣</th>
                                    <th>房间当前库存</th>
                                    <th>修改</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr th:each="room_type : ${room_types}" th:id="${room_type.room_type_id}">

                                    <td th:text="${room_type.room_type_name}">普通会员</td>
                                    <td th:text="${room_type.room_type_price}" th:class="'z'+${room_type.room_type_id}">
                                        9折
                                    </td>
                                    <td th:text="${room_type.room_type_discount}" th:class="${room_type.room_type_id}">
                                        500
                                    </td>
                                    <td th:text="${room_type.room_type_stock}" th:class="'s'+${room_type.room_type_id}">
                                        20
                                    </td>
                                    <td><!-- 按钮：用于打开模态框 -->
                                        <button type="button" class="btn btn-primary" data-toggle="modal"
                                                th:data-target="'#myModal3'+${room_type.room_type_id}"
                                                style="height: 24px;line-height: 11px;"
                                                th:onclick="fillinputroom_type([[${room_type}]])">
                                            修改
                                        </button>

                                        <!-- 模态框 -->
                                        <div class="modal fade" th:id="'myModal3'+${room_type.room_type_id}">
                                            <div class="modal-dialog">
                                                <div class="modal-content">

                                                    <!-- 模态框头部 -->
                                                    <div class="modal-header">
                                                        <h4 class="modal-title">会员规则单条修改</h4>
                                                        <button type="button" class="close" data-dismiss="modal">
                                                            &times;
                                                        </button>
                                                    </div>

                                                    <!--<form action="/systemsetting/room_type/update" method="post">-->
                                                    <!-- 模态框主体 -->
                                                    <div class="modal-body">
                                                        <input type="hidden" th:value="${room_type.room_type_id}"
                                                               name="room_type_id">
                                                        房间类型：<input type="text" class="modelinput31"
                                                                    name="room_type_name" disabled="disabled"><br>
                                                        房间价格：<input type="text" class="modelinput32"
                                                                    name="room_type_price"
                                                                    th:onfocus="clearinput7([[${room_type.room_type_id}]])"
                                                                    th:class="'x'+${room_type.room_type_id}"><br>
                                                        房间折扣：<input type="text" class="modelinput33"
                                                                    th:onfocus="clearinput5([[${room_type.room_type_id}]])"
                                                                    th:class="'y'+${room_type.room_type_id}"
                                                                    name="room_type_discount"><br>
                                                        房间当前库存：<input type="text" class="modelinput34"
                                                                      name="room_type_stock" disabled="disabled"><br>


                                                    </div>

                                                    <!-- 模态框底部 -->
                                                    <div class="modal-footer">
                                                        <input type="button" class="btn btn-primary" value="修改"
                                                               th:onclick="room_type_update([[${room_type.room_type_id}]])"
                                                               data-dismiss="modal">
                                                        <button type="button" class="btn btn-primary"
                                                                data-dismiss="modal">关闭
                                                        </button>
                                                    </div>
                                                    <!--</form>-->
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                </tbody>
                            </table>


                        </div>

                    </div>
                    <div id="roomsetting" class="container tab-pane fade"><br><!--房间设置-->
                        <input type="hidden" th:value="${flagValue}" id="roomsearchclick">
                        <div class="container">

                            <!-- 按钮：用于打开模态框 -->
                            <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#roomModal"
                                    style="height: 24px;line-height: 11px;">
                                新增房间
                            </button>
                            <br>


                            <button type="button" class="btn btn-primary" style="height: 24px;line-height: 11px;"
                                    onclick="changecleantime()">
                                修改打扫时长
                            </button>
                            输入时长：<input type="text" name="cleantime" id="cleantime" onfocus="clearthisinput()">（单位/分钟）
                            <br>

                            <button type="button" class="btn btn-primary" style="height: 24px;line-height: 11px;"
                                    onclick="searchroom()">
                                查询房间信息
                            </button>
                            房间编号：<input type="text" name="room_num" id="searchroom_num">
                            房间类型<select id="searchopt">
                            <option name="room_type_id" text="请选择房间类型"></option>
                            <option th:each="room_type:${room_types}"
                                    th:value="${room_type.room_type_id}" name="room_type_id"
                                    th:text="${room_type.room_type_name}"></option>
                        </select>

                            <!-- 模态框 -->
                            <div class="modal fade" id="roomModal">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <!-- 模态框头部 -->
                                        <div class="modal-header">
                                            <h4 class="modal-title">新增房间</h4>
                                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                                        </div>
                                        <!-- 模态框主体 -->
                                        <div class="modal-body">
                                            房间编号：<input type="text" name="room_num" style="width: 120px;"><br>
                                            房间类型：<select id="selectopt">
                                            <option th:each="room_type:${room_types}"
                                                    th:value="${room_type.room_type_id}" name="room_type_id"
                                                    th:text="${room_type.room_type_name}"></option>
                                        </select>
                                        </div>
                                        <!-- 模态框底部 -->
                                        <div class="modal-footer">
                                            <input type="button" class="btn btn-primary" value="确认添加"
                                                   onclick="addroom()" data-dismiss="modal">
                                            <button type="button" class="btn btn-primary" data-dismiss="modal">关闭
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>
                        <hr>
                        <!--<tr>
                            <td style="width: 120px; font-size: larger;color: #ea185c">&nbsp;新增房间：</td>
                            <td style="width: 220px;">房间编号：<input type="text" name="room_num" style="width: 120px;"></td>
                            <td>
                                <select>
                                    <option th:each="room_type:${room_types}" th:value="${room_type.room_type_id}"
                                            th:text="${room_type.room_type_name}"></option>
                                </select>
                            </td>
                            <td></td>
                        </tr>-->
                        <table class="table table-hover">
                            <thead class="table-primary">
                            <tr>
                                <th>房间编号</th>
                                <th>房间类型</th>
                                <th>房间状态</th>
                                <th>修改</th>
                                <th>删除</th>

                            </tr>
                            </thead>
                            <tbody>
                            <tr id="hahaha">

                            </tr>
                            <tr th:each="room : ${rooms}" th:id="'r'+${room.room_id}">

                                <td th:text="${room.room_num}">无</td>
                                <td th:text="${room.room_type_name}">无</td>
                                <td th:text="${room.state}">无</td>
                                <td><!-- 按钮：用于打开模态框 -->
                                    <button type="button" class="btn btn-primary" data-toggle="modal"
                                            th:data-target="'#roomchange'+${room.room_id}"
                                            style="height: 24px;line-height: 11px;"
                                            th:onclick="fillroomchangmodal([[${room}]])">
                                        修改
                                    </button>

                                    <!-- 模态框 -->
                                    <div class="modal fade" th:id="'roomchange'+${room.room_id}">
                                        <div class="modal-dialog">
                                            <div class="modal-content">

                                                <!-- 模态框头部 -->
                                                <div class="modal-header">
                                                    <h4 class="modal-title">房间信息修改</h4>
                                                    <button type="button" class="close" data-dismiss="modal">
                                                        &times;
                                                    </button>
                                                </div>

                                                <form action="/systemsetting/room/changeitem" method="post">
                                                    <!-- 模态框主体 -->
                                                    <div class="modal-body">
                                                        <input type="hidden" th:value="${room.room_id}"
                                                               name="room_id">
                                                        房间编号：<input type="text" name="room_num" disabled="disabled"
                                                                    class="room_num" th:value="${room.room_num}"><br>
                                                        房间类型：<select class="room_type_id" name="room_type_id">
                                                        <option th:each="room_type:${room_types}"
                                                                th:value="${room_type.room_type_id}"
                                                                th:class="'option'+${room_type.room_type_id}"
                                                                th:text="${room_type.room_type_name}"></option>
                                                    </select><br>
                                                        房间状态：<select class="room_state" name="room_state">
                                                        <option th:value="0" th:text="空闲中" class="state0"></option>
                                                        <option th:value="1" th:text="已入住" class="state1"></option>
                                                        <option th:value="2" th:text="故障中" class="state2"></option>
                                                        <option th:value="3" th:text="打扫中" class="state3"></option>
                                                    </select><br>
                                                        <input type="hidden" name="flagValue" value="searchroom">
                                                    </div>

                                                    <!-- 模态框底部 -->
                                                    <div class="modal-footer">
                                                        <input type="submit" class="btn btn-primary" value="修改">
                                                        <button type="button" class="btn btn-primary"
                                                                data-dismiss="modal">
                                                            关闭
                                                        </button>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    <button type="button" class="btn btn-primary" data-toggle="modal"
                                            style="height: 24px;line-height: 11px;"
                                            th:onclick="deleteroom([[${room}]])">删除
                                    </button>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div id="clerksetting" class="container tab-pane fade"><br><!--操作员设置-->
                        <div class="container">


                            <button type="button" class="btn btn-primary" style="height: 24px;line-height: 11px;"
                                    onclick="searchuser()">
                                根据手机号查询
                            </button>
                            手机号：<input type="text" id="searchphone"><br>

                            <button type="button" class="btn btn-primary" style="height: 24px;line-height: 11px;"
                                    onclick="searchuserbyaccount()">
                                &nbsp;&nbsp;根据账号查询&nbsp;&nbsp;
                            </button>
                            &nbsp;&nbsp;账号&nbsp;&nbsp;：<input type="text" id="searchaccount">


                        </div>
                        <hr>
                        <!--<tr>
                            <td style="width: 120px; font-size: larger;color: #ea185c">&nbsp;新增房间：</td>
                            <td style="width: 220px;">房间编号：<input type="text" name="room_num" style="width: 120px;"></td>
                            <td>
                                <select>
                                    <option th:each="room_type:${room_types}" th:value="${room_type.room_type_id}"
                                            th:text="${room_type.room_type_name}"></option>
                                </select>
                            </td>
                            <td></td>
                        </tr>-->
                        <table class="table table-hover">
                            <thead class="table-primary">
                            <tr>
                                <th>当前非用户信息</th>
                                <th>姓名</th>
                                <th>手机号</th>
                                <th>系统角色</th>
                                <th>修改</th>
                                <th>删除</th>

                            </tr>
                            </thead>
                            <tbody>
                            <tr>

                            </tr>
                            <tr th:each="user : ${users}" th:id="'u'+${user.user_id}">
                                <td><img th:src="'/images/user_images/'+${user.user_image}" alt="..."
                                         style="width:100px;vertical-align: middle;"
                                         class="img-fluid rounded-circle"></td>
                                <td th:text="${user.user_name}" style="vertical-align: middle;"></td>
                                <td th:text="${user.user_phone}" style="vertical-align: middle;">无</td>
                                <td th:text="${user.role_name}" style="vertical-align: middle;">无</td>
                                <td style="vertical-align: middle;"><!-- 按钮：用于打开模态框 -->
                                    <button type="button" class="btn btn-primary" data-toggle="modal"
                                            th:data-target="'#operatorchange'+${user.user_id}"
                                            style="height: 24px;line-height: 11px;"
                                            th:onclick="filloperatorchangemodal([[${user}]])">
                                        修改
                                    </button>

                                    <!-- 模态框 -->
                                    <div class="modal fade" th:id="'operatorchange'+${user.user_id}">
                                        <div class="modal-dialog">
                                            <div class="modal-content">

                                                <!-- 模态框头部 -->
                                                <div class="modal-header">
                                                    <h4 class="modal-title">操作员</h4>
                                                    <button type="button" class="close" data-dismiss="modal">
                                                        &times;
                                                    </button>
                                                </div>

                                                <form action="/systemsetting/user_role/change" method="post">
                                                    <!-- 模态框主体 -->
                                                    <div class="modal-body">
                                                        <div><img th:src="'/images/user_images/'+${user.user_image}"
                                                                  style="width:100px;" alt=""
                                                                  class="img-fluid rounded-circle"></div>
                                                        <br>
                                                        <br>

                                                        <input type="hidden" th:value="${user.user_id}"
                                                               name="user_id">
                                                        姓名：<input type="text" name="user_name" disabled="disabled"
                                                                  class="room_num" th:value="${user.user_name}"><br>
                                                        手机号：<input type="text" name="user_phone" disabled="disabled"
                                                                   class="room_num" th:value="${user.user_phone}"><br>
                                                        系统角色：
                                                        <select class="roleselect" name="role_id">
                                                            <option th:each="role:${roles}"
                                                                    th:value="${role.role_id}" name="role_id"
                                                                    th:text="${role.role_name}"
                                                                    th:class="'ro'+${role.role_id}"></option>
                                                        </select><br>

                                                        <input type="hidden" name="flagValue" value="searchuser">
                                                    </div>

                                                    <!-- 模态框底部 -->
                                                    <div class="modal-footer">
                                                        <input type="submit" class="btn btn-primary" value="修改">
                                                        <button type="button" class="btn btn-primary"
                                                                data-dismiss="modal">
                                                            关闭
                                                        </button>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                                <td style="vertical-align: middle;">
                                    <button type="button" class="btn btn-primary" data-toggle="modal"
                                            style="height: 24px;line-height: 11px;"
                                            th:onclick="deleterole([[${user}]])">删除
                                    </button>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div id="datacontrol" class="container tab-pane fade"><br><!--数据管理-->

                        <input type="button" onclick="dbbackup()" value="数据库备份">
                        <input type="button" onclick="dbrecover()" value="数据库恢复">

                        <!--<input type="button" onclick="buttom1()" value="测试">-->


                    </div>
                </div>
            </div>


            <!-- model -->
            <div class="modal fade" id="new_reservations_modal" tabindex="-1" role="dialog"
                 aria-labelledby="exampleModalLongTitle" aria-hidden="true" th:include="commons::reservation_modal">

            </div>
            <!-- Page Footer-->
            <footer class="main-footer" th:include="commons::common_footer"></footer>
        </div>
    </div>
</div>
<script type="text/javascript" th:inline="javascript">

    $(document).ready(function () {
        // alert("1231456");
        // location.href='/systemsetting/user_level/showall';
        $.ajax({
            url: "/systemsetting/room_type/discountall",
            type: "post",
            success: function (result) {
                $("#discountforall").val(result);

            }
        });
        $.ajax({
            url: "/systemsetting/room_type/roundmoney",
            type: "post",
            success: function (data) {
                $("#roundmoney").html(data);
                // window.location.reload();
            }
        });
        $.ajax({
            url: "/systemsetting/cleantime",
            type: "post",
            success: function (result) {

                $("#cleantime").val(result);
            }
        });

        var flagValue = $("#roomsearchclick").val();
        // alert(flagValue);
        if (flagValue != "" && flagValue != null) {
            // alert("fdsfdsfffsdf");
            if (flagValue == "searchroom") {
                $("#roomsettingclick").trigger("click");
            } else if (flagValue == "updateuser_level") {
                $("#vipsettingcilck").trigger("click");
            } else if (flagValue == "cashsettingclick") {
                $("#cashsettingclick").trigger("click");
            } else if (flagValue == "searchuser") {
                $("#clerksettingclick").trigger("click");
            }

        }
    });


    function clearinput1() {
        $("#modelinput1").val(""); // 将id=modelinput的文本框清空并获得焦点，以便重新输入
    }

    function clearinput2() {
        $("#modelinput2").val(""); // 将id=modelinput的文本框清空并获得焦点，以便重新输入
    }

    function clearinput3() {
        $("#modelinput3").val(""); // 将id=modelinput的文本框清空并获得焦点，以便重新输入
    }

    function clearinput4() {
        $("#modelinput4").val(""); // 将id=modelinput的文本框清空并获得焦点，以便重新输入
    }

    function clearthisinput() {
        $("#cleantime").val(""); // 将id=modelinput的文本框清空并获得焦点，以便重新输入
    }

    function dbbackup() {

        $.ajax({
            url: "/systemsetting/databasebackup",
            type: "post",

            success: function (result) {
                if (result == "success") {
                    alert("数据库备份成功！");
                } else {
                    alert("数据库备份失败！");
                }
            }
        });
    }

    function dbrecover() {

        $.ajax({
            url: "/systemsetting/databaserecover",
            type: "post",

            success: function (result) {
                if (result == "success") {
                    alert("数据库恢复成功！");
                } else {
                    alert("数据库恢复失败！");
                }
            }
        });
    }

    function clearinput6() {
        $("#discountforall").val(""); // 将id=discountforall的文本框清空并获得焦点，以便重新输入
    }

    function clearinput5(id) {
        $(".y" + id).val(""); // 将id=modelinput的文本框清空并获得焦点，以便重新输入
    }

    function clearinput7(id) {
        $(".x" + id).val(""); // 将id=modelinput的文本框清空并获得焦点，以便重新输入
    }

    function fillinput(name) {
        $("#modelinput1").val(name.level_name);
        $("#modelinput2").val(name.level_discount);
        $("#modelinput3").val(name.level_min_credit);
        $("#modelinput4").val(name.level_max_credit);
        // $(".modelinput").val(name).focus(); // 将id=modelinput的文本框清空并获得焦点，以便重新输入
    }

    function fillinputroom_type(name) {
        /*console.info(name);*/
        $(".modelinput31").val(name.room_type_name);
        $(".x" + name.room_type_id).val(name.room_type_price);
        $(".y" + name.room_type_id).val(name.room_type_discount);
        $(".modelinput34").val(name.room_type_stock);
        // $(".modelinput").val(name).focus(); // 将id=modelinput的文本框清空并获得焦点，以便重新输入
    }

    function fillroomchangmodal(room) {
        /*console.info(name);*/
        $(".option" + room.room_type_id).prop("selected", true);
        $(".state" + room.room_state).prop("selected", true);
        /*$(".x" + name.room_type_id).val(name.room_type_price);
        $(".y" + name.room_type_id).val(name.room_type_discount);
        $(".modelinput34").val(name.room_type_stock);*/
        // $(".modelinput").val(name).focus(); // 将id=modelinput的文本框清空并获得焦点，以便重新输入
    }

    function filloperatorchangemodal(user) {
        /*console.info(name);*/
        $(".ro" + user.role_id).prop("selected", true);

        /*$(".x" + name.room_type_id).val(name.room_type_price);
        $(".y" + name.room_type_id).val(name.room_type_discount);
        $(".modelinput34").val(name.room_type_stock);*/
        // $(".modelinput").val(name).focus(); // 将id=modelinput的文本框清空并获得焦点，以便重新输入
    }

    function deleteItem(level_id) {
        $.ajax({
            url: "/systemsetting/user_level/delete",
            type: "post",
            data: {
                level_id: level_id
            },
            success: function () {
                $("#" + level_id).remove();
                // window.location.reload();
            }
        });
    }

    function deleterole(user) {
        $.ajax({
            url: "/systemsetting/user_role/delete",
            type: "post",
            data: {
                user_id: user.user_id
            },
            success: function () {
                alert("删除成功");
                $("#u" + user.user_id).remove();
                // window.location.reload();
            }
        });
    }

    function deleteroom(room) {
        $.ajax({
            url: "/systemsetting/room/delete",
            type: "post",
            data: {
                room_id: room.room_id,
                room_type_id: room.room_type_id
            },
            success: function () {
                $("#r" + room.room_id).remove();
                $(".s" + room.room_type_id).html($(".s" + room.room_type_id).html() - 1);
                // window.location.reload();
            }
        });
    }

    function room_type_update(id) {
        var room_type_id = id;
        var room_type_discount = $(".y" + id).val();
        var room_type_price = $(".x" + id).val();
        /*alert(room_type_id+"   "+room_type_discount);*/
        // var x = $('input[name="all_discount"]:checked ').val();
        // alert(x);
        $.ajax({
            url: "/systemsetting/room_type/update",
            type: "post",
            data: {
                room_type_id: room_type_id,
                room_type_discount: room_type_discount,
                room_type_price: room_type_price
            },
            success: function () {
                // $("."+room_type_id).html(room_type_discount+"");
                // $(".z"+room_type_id).html(room_type_price+"");
                window.location.reload();
                location.href = "/systemsetting/user_level/showall?flagValue=cashsettingclick";
            }
        });
    }

    function roundmoney() {
        var round_flag = $('input[name="round_flag"]:checked ').val();
        $.ajax({
            url: "/systemsetting/room_type/roundmoney",
            type: "post",
            data: {
                round_flag1: round_flag
            },
            success: function (result) {
                $("#roundmoney").html(result);
                // window.location.reload();
            }
        });
    }

    function searchroom() {
        var room_num = $("#searchroom_num").val();
        var room_type_id = $("#searchopt option:selected").val();
        // alert(room_type_id);
        console.info(room_num + "?" + room_type_id);
        if (room_num != "" || room_type_id != "") {

            location.href = "/systemsetting/room/searchroom?room_num=" + room_num + "&room_type_id=" + room_type_id + "&flagValue=searchroom";
        } else {
            alert("请按需求格式输入");
        }

    }

    function searchuser() {
        var user_phone = $("#searchphone").val();
        // alert(room_type_id);
        if (user_phone != "") {
            location.href = "/systemsetting/user_role/searchuser?user_phone=" + user_phone + "&flagValue=searchuser";
        } else {
            alert("请输入手机号");
        }

    }

    function searchuserbyaccount() {
        var user_account = $("#searchaccount").val();
        // alert(room_type_id);
        if (user_account != "") {
            location.href = "/systemsetting/user_role/searchuserbyaccount?user_account=" + user_account + "&flagValue=searchuser";
        } else {
            alert("请输入账号");
        }

    }

    function changecleantime() {
        var cleantime = $("#cleantime").val();
        // alert(room_type_id);
        // if (user_account != "") {
        $.ajax({
            url: "/systemsetting/cleantime",
            type: "post",
            data: {
                cleantime: cleantime
            },
            success: function (result) {
                alert(result);
                $("#cleantime").val(cleantime);
            }
        });
    }

    function addroom() {
        var room_type_id = $("#selectopt option:selected").val();
        var room_num = $('input[name="room_num"]').val();
        if (room_type_id === undefined) {
            alert("请选择房间类型");
            console.info(room_type_id + " " + room_num);
        } else if (room_num == "") {
            alert("房间编号不能设置为空");
        } else {
            $.ajax({
                url: "/systemsetting/room/addroom",
                type: "post",
                data: {
                    room_type_id: room_type_id,
                    room_num: room_num
                },
                success: function (result) {
                    alert(result);
                    if (result.indexOf("成功") != -1) {
                        $(".s" + room_type_id).html(parseInt($(".s" + room_type_id).html()) + 1);
                    }
                    window.location.reload();
                }
            });
        }
    }

    function discountall(room_types) {
        var all_discount = $('input[name="all_discount"]:checked ').val();
        var room_type_price = $('input[name="room_type_price"]').val();
        var room_type_discount = $('input[name="room_type_discount"]').val();
        // alert(all_discount+" "+room_type_discount);
        $.ajax({
            url: "/systemsetting/room_type/discountall",
            type: "post",
            data: {
                all_discount1: all_discount,
                room_type_discount: room_type_discount,
                room_type_price: room_type_price
            },
            success: function (result) {
                $("#discountforall").val(result);
                alert("进入" + result);
                if (result.indexOf("全场状态") == 0) {
                    for (var i = 0; i < room_types.length; i++) {
                        ;
                        var test8 = room_types[i].room_type_id;
                        // alert(test8);
                        $("." + test8).html(room_type_discount);
                        // alert(room_type_discount);
                    }
                } else {
                    for (var i = 0; i < room_types.length; i++) {
                        ;
                        var test8 = room_types[i].room_type_id;
                        var actualdiscount = room_types[i].room_type_discount;
                        // alert(test8);
                        $("." + test8).html(actualdiscount);
                        // alert(room_type_discount);
                    }
                }
                // window.location.reload();
            }
        });
    }
</script>
</body>
</html>